<?php
class Pagemanager_Model_Insertpage implements Pagemanager_Model_Mainable{
    
    private $core_controller_notnull;
    private $core_controller_tokencheckout;
    
    private $pagemanager_data_insertpagesettings;
    private $pagemanager_data_insertmetavalues;
    private $pagemanager_data_insertpagecontentvalues;
    
    private $insert_page_settings_result;
    private $insert_page_meta_values_result;
    private $insert_page_content_values_result;
    
    private $excepted_result = 1;
    
    public function main(array $variables = null) {
        $this->core_controller_notnull = new Core_Controller_Notnull;
        $this->core_controller_notnull->main($variables);
        $this->core_controller_tokencheckout = new Core_Controller_Tokencheckout;
        $this->core_controller_tokencheckout->main($variables['post']);
        
        $this->pagemanager_data_insertpagesettings = new Pagemanager_Data_Insertpagesettings;
        $this->pagemanager_data_insertmetavalues = new Pagemanager_Data_Insertpagemetavalues;
        $this->pagemanager_data_insertpagecontentvalues = new Pagemanager_Data_Insertpagecontentvalues;
        
        $this->insert_page_settings_result = $this->pagemanager_data_insertpagesettings->main($variables);
        $this->insert_page_meta_values_result = $this->pagemanager_data_insertmetavalues->main($variables);
        $this->insert_page_content_values_result = $this->pagemanager_data_insertpagecontentvalues->main($variables);
        
        if(
                ($this->insert_page_settings_result == $this->excepted_result) &&
                ($this->insert_page_meta_values_result == $this->excepted_result) &&
                ($this->insert_page_content_values_result == $this->excepted_result)
                ){
            header("Location: ".SITE_ROOT."zarzadzaj-stronami.html");
        }
        else {
            header("Location: ".SITE_ROOT."zarzadzaj-stronami.html");
        }
    }

}
